package com.lianniu.web.staff.service.impl;

import com.lianniu.web.base.BaseResult;
import com.lianniu.web.buyerOrder.model.OrderDetailVo;
import com.lianniu.web.buyerOrder.model.OrderInfoVo;
import com.lianniu.web.product.model.Page;
import com.lianniu.web.staff.dao.StaffOrderDao;
import com.lianniu.web.staff.service.StaffOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2017-05-18.
 */
@Service
public class StaffOrderServiceImpl implements StaffOrderService {

    @Autowired
    StaffOrderDao staffOrderDao;

    @Override
    public BaseResult getOrders(String staffId, String approveStatus, int pageNum) {
        int count = this.staffOrderDao.getOrdersCount(staffId, approveStatus);
        Page page = new Page(count, pageNum);
        List<OrderInfoVo> orders = this.staffOrderDao.getOrders(staffId, approveStatus, page);
        return BaseResult.success(orders);
    }

    @Override
    public BaseResult getOrderById(String orderId) {
        OrderInfoVo orderInfoVo = this.staffOrderDao.getOrderById(orderId);
        return BaseResult.success(orderInfoVo);
    }

    @Override
    public BaseResult updateOrderDetail(OrderDetailVo orderDetailVo) {
        int i = this.staffOrderDao.updateOrderDetail(orderDetailVo);
        return BaseResult.success(i);
    }

    @Override
    public BaseResult updateOrderInfo(OrderInfoVo orderInfoVo) {
        int i = this.staffOrderDao.updateOrderInfo(orderInfoVo);
        return BaseResult.success(i);
    }
}
